package com.dq;

import org.mybatis.spring.annotation.MapperScan;
import com.dq.utils.SpringUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@ComponentScan
@EnableScheduling
@EnableAsync
@EnableSwagger2
@EnableTransactionManagement
//@MapperScan(basePackages = {"com.**"})
public class SysApplication {

    /**
     * 关于事务管理器，不管是JPA还是JDBC等都实现自接口 PlatformTransactionManager
     * 如果你添加的是 spring-boot-starter-jdbc 依赖，框架会默认注入 DataSourceTransactionManager 实例。
     * 如果你添加的是 spring-boot-starter-data-jpa 依赖，框架会默认注入 JpaTransactionManager 实例。
     * @param platformTransactionManager
     * @return
     */
    @Bean
    public  Object testBean(PlatformTransactionManager platformTransactionManager){
        System.out.println(">>>>>>>>>>" + platformTransactionManager.getClass().getName());
        return new Object();
    }

    public static void main(String[] args) {
        try {
            ApplicationContext app = SpringApplication.run(SysApplication.class, args);
            SpringUtil.setApplicationContext(app);
            System.out.println();
        }catch (Exception e) {
            e.printStackTrace();
        }
    }

}
